package edu.whu;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Main {
    public static void main(String[] args) throws NoSuchMethodException {
        try {
            Properties prop = new Properties();
            InputStream input=Main.class.getResourceAsStream("/myapp.properties");
            prop.load(input);
            Class bootStrap=Class.forName(prop.getProperty("bootStrapClass").toString());
            Method[] methods = bootStrap.getMethods();
            Object obj = bootStrap.getConstructor().newInstance();
            for (Method method : methods) {
                if (method.isAnnotationPresent(initMethod.class)){
                    //通过 obj 对象来执行 method 方法
                    method.invoke(obj);
                }
            }
        }catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException|IllegalArgumentException e){
            e.printStackTrace();
        }
    }

}
